package com.zys.hotel_management.service.impl;

import com.zys.hotel_management.mapper.BookingMapper;
import com.zys.hotel_management.mapper.RoomMapper;
import com.zys.hotel_management.service.CheckInService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

@Service
public class CheckInServiceImpl implements CheckInService {
    @Resource
    private BookingMapper bookingMapper;
    @Resource
    private RoomMapper roomMapper;

    @Override
    public void checkIn(Integer bookingId) {
        bookingMapper.updateStatus(bookingId, "已入住");
        Integer roomId = bookingMapper.findById(bookingId).getRoomId();
        roomMapper.updateStatus(roomId, "占用");
    }

    @Override
    public void checkOut(Integer bookingId) {
        bookingMapper.updateStatus(bookingId, "已退房");
        Integer roomId = bookingMapper.findById(bookingId).getRoomId();
        roomMapper.updateStatus(roomId, "空闲");
    }
}